﻿using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Mvc;

namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
    
    public class SysProductController : BaseController
    {
        private readonly ISysProductServer _sysProductServer;

        public SysProductController(ISysProductServer sysProductServer) {
            _sysProductServer = sysProductServer;
        }
        /// <summary>
        /// 产品分页
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="key"></param>
        /// <param name="carShopId"></param>
        /// <returns></returns>
        [HttpGet]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { new string[] { "admin", "carShop" ,"user" } })]
        public async Task<IActionResult> Pagination(int page,int limit,string key,string carShopId,string category)
        {
            return Send(await _sysProductServer.PaginationAsync(page,limit,key,carShopId,category));
        }
        /// <summary>
        /// 产品详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { new string[] { "admin", "carShop" ,"user" } })]
        public async Task<IActionResult> Detail(string id)
        {
            return Send(await _sysProductServer.Detail(id));
        }
    }
}
